# eric7.WebBrowser.Session.SessionManager

Module implementing the session manager.

### Global Attributes

None

### Classes

SessionManager | Class implementing the session manager.
SessionMetaData | Class implementing a data structure to store meta data for a session.

### Functions

None

## SessionManager

Class implementing the session manager.

### Signals

sessionsMetaDataChanged()
  emitted to indicate a change of the list of session meta data

### Derived from

QObject

### Class Attributes

CloneSession
ReplaceSession
RestoreSession
SwitchSession

### Class Methods

isValidSession | Class method to check the validity of a session.
readSessionFromFile | Class method to read the session data from a file.
restoreSessionFromData | Class method to restore a session from a session data dictionary.

### Methods

SessionManager | Constructor
__autoSaveSession | Private slot to save the current session state.
__backupSavedSession | Private method to backup the most recently saved session.
__fillMetaDataList | Private method to fill the sessions meta data list.
__initSessionSaveTimer | Private slot to initialize the auto save timer.
__isActive | Private method to check, if a given file is the active one.
__sessionActTriggered | Private slot to handle the menu selection of a session.
__sessionDirectoryChanged | Private slot handling changes of the sessions directory.
aboutToShowSessionsMenu | Public slot to populate the sessions selection menu.
activateTimer | Public method to activate the session save timer.
autoSaveSession | Public method to save the current session state.
cloneSession | Public method to clone a session.
defaultSessionFile | Public method to get the name of the default session file.
deleteSession | Public method to delete a session.
getSessionsDirectory | Public method to get the directory sessions are stored in.
lastActiveSessionFile | Public method to get the name of the last active session file.
newSession | Public method to start a new session.
openSession | Public method to open a session from a given session file.
preferencesChanged | Public slot to react upon changes of the settings.
renameSession | Public method to rename or clone a session.
replaceSession | Public method to replace the current session with the given one.
saveSession | Public method to save the current session.
selectSession | Public method to select a session to be restored.
sessionMetaData | Public method to get the sessions meta data.
showSessionManagerDialog | Public method to show the session manager dialog.
shutdown | Public method to perform any shutdown actions.
switchToSession | Public method to switch the current session to the given one.
writeCurrentSession | Public method to write the current session to the given file name.

### Static Methods

None

#### SessionManager.isValidSession (class method)

isValidSession(session)

Class method to check the validity of a session.

session (dict)
  dictionary containing the session data

Return:
  flag indicating validity

Return Type:
  bool

#### SessionManager.readSessionFromFile (class method)

readSessionFromFile(sessionFileName)

Class method to read the session data from a file.

sessionFileName (str)
  file name of the session file

Return:
  dictionary containing the session data

Return Type:
  dict

#### SessionManager.restoreSessionFromData (class method)

restoreSessionFromData(window=None, sessionData=None)

Class method to restore a session from a session data dictionary.

window (WebBrowserWindow)
  reference to main window to restore to
sessionData (dict)
  dictionary containing the session data

#### SessionManager (Constructor)

SessionManager(parent=None)

Constructor

parent (QObject)
  reference to the parent object

#### SessionManager.__autoSaveSession

__autoSaveSession(startTimer=True)

Private slot to save the current session state.

startTimer (bool)
  flag indicating to restart the timer

#### SessionManager.__backupSavedSession

__backupSavedSession()

Private method to backup the most recently saved session.

#### SessionManager.__fillMetaDataList

__fillMetaDataList()

Private method to fill the sessions meta data list.

The sessions meta data list is only populated, if the variable holding it is empty (i.e. it is populated on demand).

#### SessionManager.__initSessionSaveTimer

__initSessionSaveTimer()

Private slot to initialize the auto save timer.

#### SessionManager.__isActive

__isActive(filePath)

Private method to check, if a given file is the active one.

filePath (str or pathlib.Path)
  path of the session file to be checked

Return:
  flag indicating the active file

Return Type:
  bool

#### SessionManager.__sessionActTriggered

__sessionActTriggered(act)

Private slot to handle the menu selection of a session.

act (QAction)
  reference to the action that triggered

#### SessionManager.__sessionDirectoryChanged

__sessionDirectoryChanged(path)

Private slot handling changes of the sessions directory.

path (str)
  name of the changed directory

#### SessionManager.aboutToShowSessionsMenu

aboutToShowSessionsMenu(menu)

Public slot to populate the sessions selection menu.

menu (QMenu)
  reference to the menu about to be shown

#### SessionManager.activateTimer

activateTimer()

Public method to activate the session save timer.

#### SessionManager.autoSaveSession

autoSaveSession()

Public method to save the current session state.

#### SessionManager.cloneSession

cloneSession(sessionFilePath)

Public method to clone a session.

sessionFilePath (str)
  file name of the session file to be cloned

#### SessionManager.defaultSessionFile

defaultSessionFile()

Public method to get the name of the default session file.

Return:
  name of the default session file

Return Type:
  str

#### SessionManager.deleteSession

deleteSession(sessionFilePath)

Public method to delete a session.

sessionFilePath (str)
  file name of the session file to be deleted

#### SessionManager.getSessionsDirectory

getSessionsDirectory()

Public method to get the directory sessions are stored in.

Return:
  name of the sessions directory

Return Type:
  str

#### SessionManager.lastActiveSessionFile

lastActiveSessionFile()

Public method to get the name of the last active session file.

Return:
  name of the last active session file

Return Type:
  str

#### SessionManager.newSession

newSession()

Public method to start a new session.

#### SessionManager.openSession

openSession(sessionFilePath, flags=0)

Public method to open a session from a given session file.

sessionFilePath (str)
  name of the session file to get session from
flags (int)
  flags determining the open mode

#### SessionManager.preferencesChanged

preferencesChanged()

Public slot to react upon changes of the settings.

#### SessionManager.renameSession

renameSession(sessionFilePath, flags=0)

Public method to rename or clone a session.

sessionFilePath (str)
  name of the session file
flags (int)
  flags determining a rename or clone operation

#### SessionManager.replaceSession

replaceSession(sessionFilePath)

Public method to replace the current session with the given one.

sessionFilePath (str)
  file name of the session file to replace with

Return:
  flag indicating success

Return Type:
  bool

#### SessionManager.saveSession

saveSession()

Public method to save the current session.

#### SessionManager.selectSession

selectSession()

Public method to select a session to be restored.

Return:
  name of the session file to be restored

Return Type:
  str

#### SessionManager.sessionMetaData

sessionMetaData(includeBackups=False)

Public method to get the sessions meta data.

includeBackups (bool)
  flag indicating to include backup sessions

Return:
  list of session meta data

Return Type:
  list of SessionMetaData

#### SessionManager.showSessionManagerDialog

showSessionManagerDialog()

Public method to show the session manager dialog.

#### SessionManager.shutdown

shutdown()

Public method to perform any shutdown actions.

#### SessionManager.switchToSession

switchToSession(sessionFilePath)

Public method to switch the current session to the given one.

sessionFilePath (str)
  file name of the session file to switch to

Return:
  flag indicating success

Return Type:
  bool

#### SessionManager.writeCurrentSession

writeCurrentSession(sessionFileName)

Public method to write the current session to the given file name.

sessionFileName (str)
  file name of the session

Up

## SessionMetaData

Class implementing a data structure to store meta data for a session.

### Derived from

None

### Class Attributes

filePath
isActive
isBackup
isDefault
name

### Class Methods

None

### Methods

None

### Static Methods

None

Up